<?php
/**
 * +--------------------------------------------------------+
 * @Created by Phpstorm.
 * @Category Update.php
 * @Depiction
 * @Author hwy
 * @Date 2021/5/25  15:33
 * +--------------------------------------------------------+
 */

namespace App\Http\Requests\Role;


use App\Http\Requests\BaseRequestsPost;
use App\Rules\AlphaNumRule;

class Update extends BaseRequestsPost
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'display_name' => ['required', 'unique:roles,display_name,' . $this->route('id')],
            'name'         => ['required', 'unique:roles,name,' . $this->route('id')],
        ];

        return $rules;
    }

    /**
     * 定义字段名中文
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'name' => '角色名',
            'name' => '标识',
        ];
    }

    public function messages()
    {
        return [
            'display_name.required' => '角色名不能为空！',
            'display_name.unique'   => '角色名已存在！',
            'name.required'         => '标识不能为空！',
            'name.unique'           => '标识已存在！',
        ];
    }

}